home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / maxidi22.lzh / TOS / URAN_XB.S < prev   
Encoding:
Text File  |  1992-02-07  |  3.7 KB  |  181 lines

  1. ; File name:    URAn_XB.S    Revised:  1991.07.04
  2. ; Creator:    U.R.Andersson    Created:  1991.05.07
  3. ; (c)1991 by:    U.R.Andersson    All rights reserved
  4. ; Released as:    FREEWARE    (NB: commercial sales forbidden!)
  5. ;
  6. ; File purpose:    Defines 9 macros to implement XBRA function protocol
  7. ;
  8. ;   The first 4 alter no registers
  9. ; XB_define    xbstruct,xbra_id    Defines header for XBRA function code
  10. ; XB_gonext    xbstruct        Links to next XBRA function in chain
  11. ; XB_gonext_d    xbstruct        Links to next XBRA function in chain
  12. ; XB_donext_d    xbstruct        Calls next XBRA subroutine in chain
  13. ;
  14. ;   The next 2 alter only the choosen "areg"
  15. ; Find_Frame    areg            areg->exception argument -6
  16. ; XB_donext    xbstruct,areg        Calls next XBRA function in chain
  17. ;
  18. ;   The next 3 affect d0-d2/a0-a2, since they use XBIOS Supexec
  19. ; XB_check    xbstruct,root        d0= found_codead/zero  flagged NE/EQ
  20. ;   -"-           -"-            a0->found_vector/last_vector 
  21. ; XB_install    xbstruct,root        Installs xbstruct in chain(root)
  22. ; XB_remove    xbstruct,root        Removes xbstruct from chain(root)
  23. ;
  24. ; Legal forms for xbstruct & root here are mostly the same as for LEA & PEA,
  25. ;   except that for XB_define "xbstruct" is a free name for the new structure.
  26. ; "xbstruct" always refers to the first byte of the entire structure.
  27. ; "xbra_id" is a 4-character (longword) string
  28. ; "areg" is a free address register of your choice.
  29. ; XB_gonext_d & XB_donext_d are faster versions of XB_gonext & XB_donext,
  30. ;   but can only handle address modes where "xbstruct" begins with identifier.
  31. ;   eg: "XB_donext_d  my_ikbd_sub(pc)"  but  "XB_donext  (a5)+")
  32. ; Find_Frame makes XBRA exception functions (eg: gemdos etc.) TT compatible.
  33. ;
  34. ;    Macro definitions (with support variables)
  35. ;
  36. ;
  37. Find_Frame    macro    areg
  38.     btst    #5,(sp)
  39.     beq.s    .user\@
  40.     move.l    sp,\1
  41.     tst    $59E.w
  42.     beq.s    .framed\@
  43.     addq    #2,\1
  44.     bra.s    .framed\@
  45. .user\@:
  46.     move    USP,\1
  47.     subq    #6,\1
  48. .framed\@:
  49.     endm
  50. ;
  51. ;
  52. XB_define    macro    xbstructname,xbra_id
  53. \1:    dc.l    'XBRA',\2,0
  54.     endm
  55. ;
  56. ;
  57. XB_donext_d    macro    xbstruct
  58.     move.l    8+\1,-(sp)
  59.     jsr    (sp)+
  60.     endm
  61. ;
  62. ;
  63. XB_donext    macro    xbstruct,areg
  64.     lea    \1,\2
  65.     move.l    8(\2),\2
  66.     jsr    (\2)
  67.     endm
  68. ;
  69. ;
  70. XB_gonext_d    macro    xbstruct
  71.     move.l    8+\1,-(sp)
  72.     rts
  73.     endm
  74. ;
  75. ;
  76. XB_gonext    macro    xbstruct
  77.     movem.l    a0-a1,-(sp)
  78.     lea    \1,a0
  79.     move.l    8(a0),4(sp)
  80.     move.l    (sp)+,a0
  81.     rts
  82.     endm
  83. ;
  84. ;
  85. zzXBccnt    set    0
  86. ;
  87. XB_check    macro    xbstruct,root
  88.     ifne    zzXBccnt=0
  89.     bra    zzXBcend
  90. zzXBcsub:
  91.     move.l    8(sp),a0
  92.     move.l    12(sp),a1
  93. zzXBchlp:
  94.     move.l    a1,d1
  95.     move.l    (a1),d0
  96.     beq.s    zzXBcrts
  97.     move.l    d0,a1
  98.     subq.l    #4,a1
  99.     clr.l    d0
  100.     cmpi.l    #'XBRA',-8(a1)
  101.     bne.s    zzXBcrts
  102.     move.l    -4(a1),d0
  103.     cmp.l    4(a0),d0
  104.     bne.s    zzXBchlp
  105. zzXBcrts:    ;d1->last legal vector in chain or vector for current XBRA
  106. ;    ...    ;d0= zero or code address of current XBRA
  107.     move.l    d1,a0
  108.     rts    ;d0=zero/codeadr of found XBRA a0->last/found vector
  109. zzXBcend:
  110.     endc
  111.     pea    \2
  112.     pea    \1
  113.     pea    zzXBcsub
  114.     move    #$26,-(sp)
  115.     trap    #14
  116.     add.w    #14,sp
  117.     tst.l    d0
  118. zzXBccnt    set    zzXBccnt+1
  119.     endm
  120. ;
  121. ;
  122. zzXBicnt    set    0
  123. ;
  124. XB_install    macro    xbstruct,root
  125.     ifne    zzXBicnt=0
  126.     bra    zzXBiend
  127. zzXBisub:
  128.     move.l    8(sp),a0
  129.     move.l    12(sp),a1
  130.     XB_check    (a0),(a1)
  131.     bne    zzXBirts
  132.     move.l    8(sp),a0
  133.     move.l    12(sp),a1
  134.     lea    8(a0),a0
  135.     move    SR,-(sp)
  136.     ori    #$0700,SR
  137.     move.l    (a1),(a0)+
  138.     move.l    a0,(a1)
  139.     move    (sp)+,SR
  140. zzXBirts:
  141.     rts    
  142. zzXBiend:
  143.     endc
  144.     pea    \2
  145.     pea    \1
  146.     pea    zzXBisub
  147.     move    #$26,-(sp)
  148.     trap    #14
  149.     add.w    #14,sp
  150. zzXBicnt    set    zzXBicnt+1
  151.     endm
  152. ;
  153. ;
  154. zzXBrcnt    set    0
  155. ;
  156. XB_remove    macro    xbstruct,root
  157.     ifne    zzXBrcnt=0
  158.     bra    zzXBrend
  159. zzXBrsub:
  160.     move.l    8(sp),a0
  161.     move.l    12(sp),a1
  162.     XB_check    (a0),(a1)
  163.     beq.s    zzXBrrts
  164.     move.l    (a0),a1
  165.     move.l    -4(a1),(a0)
  166. zzXBrrts:
  167.     rts    
  168. zzXBrend:
  169.     endc
  170.     pea    \2
  171.     pea    \1
  172.     pea    zzXBrsub
  173.     move    #$26,-(sp)
  174.     trap    #14
  175.     add.w    #14,sp
  176. zzXBrcnt    set    zzXBrcnt+1
  177.     endm
  178. ;
  179. ;
  180. ; End of file:    URAn_XB.S
  181.